<?php

namespace iBrand\Shop\Backend\Http\Middleware;

use Closure;
use Session;
use Illuminate\Contracts\Auth\Guard;

class ShopIdRequestMiddleware
{

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if (($request->is('admin/shop/info*')
                OR ($request->is('admin/warehouse*')) OR ($request->is('admin/report*')))
            && !Session::has('shop_id')) {

            admin_toastr('请点击门店管理，管理相关门店', 'warning');

            return redirect()->route('admin.shop.list.store');
        }

        return $next($request);
    }

}